package com.gxa.order.service.impl;

import entity.OrderFight;
import com.gxa.order.dao.OrderFightDao;
import com.gxa.order.service.OrderFightService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (OrderFight)表服务实现类
 *
 * @author makejava
 * @since 2021-05-11 09:23:42
 */
@Service("orderFightService")
public class OrderFightServiceImpl implements OrderFightService {
    @Resource
    private OrderFightDao orderFightDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderFightId 主键
     * @return 实例对象
     */
    @Override
    public OrderFight queryById(Integer orderFightId) {
        return this.orderFightDao.queryById(orderFightId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<OrderFight> queryAllByLimit(int offset, int limit) {
        return this.orderFightDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param orderFight 实例对象
     * @return 实例对象
     */
    @Override
    public OrderFight insert(OrderFight orderFight) {
        this.orderFightDao.insert(orderFight);
        return orderFight;
    }

    /**
     * 修改数据
     *
     * @param orderFight 实例对象
     * @return 实例对象
     */
    @Override
    public OrderFight update(OrderFight orderFight) {
        this.orderFightDao.update(orderFight);
        return this.queryById(orderFight.getOrderFightId());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderFightId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderFightId) {
        return this.orderFightDao.deleteById(orderFightId) > 0;
    }
}
